package com.wc.alorithm_blue_bridge._数据结构.AC自动机.Q4202;

import java.util.*;
import java.io.*;

/**
 * @Author congege
 * @Description AC自动机的板子
 * @Date Created in 2023/12/4-22:23
 */
public class Main {
    static int maxN = (int) 1e5 + 10;
    static int[][] son = new int[maxN][26];
    static int[] val = new int[maxN];
    static int[] cnt = new int[maxN];
    static int[] fail = new int[maxN];
    static Map<Integer, String> map = new HashMap<>();
    static int idx = 0;
    static int ansLen = 0;
    static Set<String> ansSet;
    static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

    public static void main(String[] args) {
        String s = nextLine();
        int n = nextInt();
        ansSet = new TreeSet<>();
        while (n-- > 0) {
            insert(nextLine());
        }
        build();
        query(s);
        out.println(ansLen);
        for (String sub : ansSet) {
            out.println(sub);
        }
        out.flush();
    }

    public static String nextLine() {
        String s = "";
        try {
            s = reader.readLine();
        } catch (Exception e) {
            return s;
        }
        return s;
    }

    public static int nextInt() {
        return Integer.parseInt(nextLine());
    }

    public static void insert(String word) {
        int p = 0;

        for (char c : word.toCharArray()) {
            int u = c - 'a';
            if (son[p][u] == 0) {
                son[p][u] = ++idx;
            }
            p = son[p][u];
        }
        map.put(p, word);
        ++cnt[p];
    }

    public static void build() {
        int p = 0;
        Queue<Integer> q = new LinkedList<>();
        for (int i = 0; i < 26; i++) {
            if (son[p][i] > 0) {
                q.add(son[p][i]);
            }
        }
        while (q.size() != 0) {
            p = q.poll();
            for (int i = 0; i < 26; i++) {
                if (son[p][i] > 0) {
                    fail[son[p][i]] = son[fail[p]][i];
                    q.add(son[p][i]);
                } else {
                    son[p][i] = son[fail[p]][i];
                }
            }
        }
    }

    public static void query(String s) {
        int p = 0;
        for (char c : s.toCharArray()) {
            int u = c - 'a';
            p = son[p][u];
            for (int i = p; i != 0; i = fail[i]) {
                if (cnt[i] > 0) {
                    val[i]++;
                    if (val[i] >= ansLen) {
                        if (val[i] > ansLen) {
                            ansLen = val[i];
                            ansSet = new TreeSet<>();
                        }
                        ansSet.add(map.get(i));
                    }
                }
            }
        }
    }
}
